# $Id$
# Maintainer: Guillaume ALAUX <guillaume@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>

pkgname=eclipse-ecj
pkgver=4.6.1
pkgrel=1
_date=201609071200
pkgdesc='Eclipse java bytecode compiler'
arch=('any')
license=('EPL')
url='http://www.eclipse.org/'
depends=('java-runtime')
makedepends=('apache-ant' 'java-environment')
_base_url=http://download.eclipse.org/eclipse/downloads/drops4
_sum_file_url=${_base_url}/R-${pkgver}-${_date}/checksum/eclipse-${pkgver}-SUMSSHA512
_source_file_name=ecjsrc-${pkgver}.jar
source=(${_base_url}/R-${pkgver}-${_date}/${_source_file_name}
        ${_sum_file_url}{,.asc}
        01-ecj-include-props.patch
        02-buildxml-fix-manifest.patch
        ecj)
validpgpkeys=('869FF7E31C98FBCFCF167CDE01D81CA560A48EFD') # Eclipse Project

_source_file_sum=$(curl ${_sum_file_url} | grep -m 1 ${_source_file_name} | cut -d ' ' -f 1)
sha512sums=(${_source_file_sum}
            'ae98861af1ab9d2a90a3d1660700de2c5654a272f1c3d0af0698dc6d1827d3a2e2ccda4690eff706836f87bf0d5e1fbe283121ab41da7087c8618fc3fecb4d27'
            'SKIP'
            '72c8a2437333e8068e60e1a035bf4e5e9b66881fc06936600a6867dc7e4eb4670f94c4b2392634ebb28f85f8fdf88248ccb9cc315717e257ce336b495c2f2d68'
            '11ca94869d71842401e48acca72fd89e339ba65c81909cf8501bb243457caa21dc659d268b98c42ac77a1834fb7de46138787e8ea0966d96324c8de829fe563c'
            '1895c12c63262a08a2c889bb1db61308b5cb8846e5f20e584cde6878afd4da5ee051045a61a0a5a4498146a7315c8a14bf120e5d369365f4efc573d371381846')

build() {
  cd "${srcdir}"
  for p in 01-ecj-include-props 02-buildxml-fix-manifest; do
    patch -p0 < ${p}.patch
  done
  export LANG=en_US.UTF-8
  ant build
}

package() {
  install -Dm644 "${srcdir}/ecj.jar" "${pkgdir}/usr/share/java/eclipse-ecj-${pkgver}.jar"
  ln -s eclipse-ecj-${pkgver}.jar "${pkgdir}/usr/share/java/ecj.jar"
  ln -s eclipse-ecj-${pkgver}.jar "${pkgdir}/usr/share/java/eclipse-ecj.jar"
  install -Dm755 ecj "${pkgdir}/usr/bin/ecj"
  install -D -m 644 ecj.1 "${pkgdir}/usr/share/man/man1/ecj.1"
}
